package com.team9.fitness.controller;

import com.team9.fitness.entity.Diet;
import com.team9.fitness.service.DietService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/api/diet")
@CrossOrigin(origins = { "*" }, allowCredentials = "false")
public class DietController {

    @Autowired
    private DietService dietService;

    @PostMapping("/save/{id}/{diets}")
    public ResponseEntity<Map<String,Object>> save(
            @PathVariable Long id,@PathVariable List<Diet> diets ){
        return dietService.save(id,diets);
    }

    @GetMapping("/getAll")
    public ResponseEntity<Map<String,Object>> getAll(){
        return dietService.getAll();
    }

}
